package com.wd.live.view.activity;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentPagerAdapter;

import android.os.Bundle;
import android.widget.RadioGroup;

import com.wd.live.R;
import com.wd.live.base.BaseActivity;
import com.wd.live.base.BaseViewModel;
import com.wd.live.databinding.ActivityMainBinding;
import com.wd.live.view.fragment.BroadcastFragment;
import com.wd.live.view.fragment.ListFragment;
import com.wd.live.view.fragment.MyFragment;
import com.wd.live.view.fragment.NearFragment;
import com.wd.live.view.fragment.SquareFragment;

import java.util.ArrayList;

import io.agora.rtc2.IRtcEngineEventHandler;

public class MainActivity extends BaseActivity<BaseViewModel, ActivityMainBinding> {


        @Override
        protected void initData() {
            ArrayList<Fragment> list = new ArrayList<>();
            list.add(new SquareFragment());
            list.add(new NearFragment());
            list.add(new BroadcastFragment());
            list.add(new ListFragment());
            list.add(new MyFragment());
            databind.mainVp.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
                @NonNull
                @Override
                public Fragment getItem(int position) {
                    return list.get(position);
                }

                @Override
                public int getCount() {
                    return list.size();
                }
            });
            databind.bottomRg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(RadioGroup group, int checkedId) {
                    switch (checkedId) {
                        case R.id.bottom_rb1:
                            databind.mainVp.setCurrentItem(0);
                            break;
                        case R.id.bottom_rb2:
                            databind.mainVp.setCurrentItem(1);
                            break;
                        case R.id.bottom_rb3:
                            databind.mainVp.setCurrentItem(2);
                            break;
                        case R.id.bottom_rb4:
                            databind.mainVp.setCurrentItem(3);
                            break;
                        case R.id.bottom_rb5:
                            databind.mainVp.setCurrentItem(4);
                            break;
                    }
                }
            });
        }

        @Override
        protected int initLayout() {
            return R.layout.activity_main;
        }

        @Override
        public void onChanged(Object o) {

        }
    }
